<?php
namespace Apps\Back;

use Phalcon\DiInterface;
use Phalcon\Loader;
use Phalcon\Mvc\View;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Phalcon\Mvc\ModuleDefinitionInterface;


class Module implements ModuleDefinitionInterface
{
    /**
     * Registers an autoloader related to the module
     *
     * @param DiInterface $di
     */
    public function registerAutoloaders(DiInterface $di = null)
    {

        $loader = new Loader();

        $loader->registerNamespaces(array(
            'Apps\Back\Controllers' => __DIR__.'/controllers/',
            'Apps\Model' => __DIR__.'/../models/',
            'Apps\Back\Config' => __DIR__.'/config/'
           
        ));

        $loader->register();
    }

    /**
     * Registers services related to the module
     *
     * @param DiInterface $di
     */
    public function registerServices(DiInterface $di)
    {
        /**
         * Read configuration
         */
      //  $config = include APP_PATH . "/apps/back/config/config.php";

        /**
         * Setting up the view component
         */
        $di['view'] = function () {
            $view = new View();
            $view->setViewsDir(__DIR__ . '/views/');
            $view->registerEngines(
            array(
                ".html" => 'Phalcon\Mvc\View\Engine\Php'
            ));
            return $view;
        };

        /**
         * Database connection is created based in the parameters defined in the configuration file
         */
        
    }
}
    